home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / MosaicSRC / libwww2 / HTIcon.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  1.6 KB  |  71 lines

  1. /*
  2. ** Author: Charles Henrich (henrich@crh.cl.msu.edu) October 2, 1993
  3. **
  4. ** This routine takes two parameters, Format (as returned by HTFileFormat)
  5. ** and a default icon type.  The type is the first half of the MIME type field
  6. ** (i.e. image from image/jpeg).  If the icon type cannot be determined from
  7. ** the format or from the default, then the unknown icon is returned.
  8. **
  9. ** Note: This routine gurantee's to return something!
  10. ** 
  11. */
  12.  
  13. #include "HTFile.h"
  14. #include "HTAtom.h"
  15.  
  16. struct typemap
  17. {
  18.   char *format;
  19.   char *image;
  20. };
  21.  
  22. struct typemap type_map[] =
  23. {
  24.   {"image",       "internal-gopher-image"},
  25.   {"text",        "internal-gopher-text"},
  26.   {"audio",       "internal-gopher-sound"},
  27.   {"application", "internal-gopher-binary"},
  28.   {"message",     "internal-gopher-text"},
  29.   {"video",       "internal-gopher-movie"},
  30.   {"directory",   "internal-gopher-menu"},
  31.   {"unknown",     "internal-gopher-unknown"},
  32.   {"EOFEOF",      "EOFEOF"}
  33. };
  34.  
  35. char *HTgeticonname(HTFormat format, char *defaultformat)
  36. {
  37.   int count;
  38.   char *ptr;
  39.   char subtype[128];
  40.   
  41.   if(format != NULL)
  42.     {
  43.       strcpy(subtype, format->name);
  44.       
  45.       ptr=strchr(subtype,'/');
  46.       
  47.       if(ptr != NULL) 
  48.         *ptr = '\0';
  49.     }
  50.   else
  51.     {
  52.       subtype[0] = '\0';
  53.     }
  54.   
  55.   ptr = NULL;
  56.   
  57.   for(count = 0;strcmp(type_map[count].image,"EOFEOF") != 0; count++)
  58.     {
  59.       if(strcmp(type_map[count].format, subtype) == 0)
  60.         return type_map[count].image;
  61.       
  62.       if(strcmp(type_map[count].format, defaultformat) == 0)
  63.         ptr = type_map[count].image;
  64.     }
  65.   
  66.   if(ptr != NULL) 
  67.     return ptr;
  68.   
  69.   return "internal-gopher-unknown";
  70. }
  71.